<div id="content" class="clearfix">
  <h3><?php echo $this->title;?></h3>
<?php $form=$this->beginWidget('ActiveForm', array(
	'id'=>'login-form',
	'method'=>'get',
	'action'=>$this->createUrl('report/general'),
	'enableClientValidation'=>true,
	'clientOptions'=>array(
		'validateOnSubmit'=>false,
	),
)); ?>
    <div class="section">
      <h4 class="heading_bg">查询条件</h4>
      <!--      <h5>合约销售查询</h5>-->
      <table width="100%" border="0" cellpadding="0" cellspacing="0" class="normal">
        <tr>
          <th class="tleft"><?php echo $form->label($model,'start_date'); ?></th>
          <td>
          	<?php   
			$this->widget('zii.widgets.jui.CJuiDatePicker',array(  
			    'attribute'=>'start_date',  
			    'language'=>'zh_cn',  
			    'model'=>$model,  
			    'options'=>array(  
			        'showAnim'=>'fold',
			        //'minDate'=>'new Date()',  
			        'dateFormat'=>'yy-mm-dd',  
			    ),
			));  
			?> 
          </td>
          <th class="tleft"><?php echo $form->label($model,'end_date'); ?></th>
          <td>
          	<?php   
			$this->widget('zii.widgets.jui.CJuiDatePicker',array(  
			    'attribute'=>'end_date',  
			    'language'=>'zh_cn',  
			    'model'=>$model,  
			    'options'=>array(  
			        'showAnim'=>'fold',
			        //'minDate'=>'new Date()',  
			        'dateFormat'=>'yy-mm-dd',  
			    ),
			));  
			?> 
          </td>
        </tr>
        <?php if(Yii::app()->user->checkAccess('MENU2_LJXSRB_QQ')) { ?>
		<tr>
          <th class="tleft"><?php echo $form->label($model,'eparchy_code'); ?></th>
          <td id="select">            
            <?php echo $form->dropDownList($model,'eparchy_code',Eparchy::model()->getListData(),array('prompt'=>'---------','onchange'=>'departEparchyChange(\''.$form->getClientId($model,'eparchy_code').'\',\''.$form->getClientId($model,'depart_code').'\',true)',)); ?>
            <?php echo $form->error($model,'eparchy_code'); ?>
          </td>
          <th class="tleft"><?php echo $form->label($model,'depart_code'); ?></th>
          <td id="select">
            <?php echo $form->dropDownList($model,'depart_code',Depart::model()->getListDataByEparchy($model->eparchy_code),array('prompt'=>'---------',)); ?>
            <?php echo $form->error($model,'product_id'); ?>
          </td>
        </tr>
        <?php } else if(Yii::app()->user->checkAccess('MENU2_LJXSRB_DS')) { ?>
		<tr>
          <th class="tleft"><?php echo $form->label($model,'depart_code'); ?></th>
          <td colspan="3" id="select">            
            <?php echo $form->dropDownList($model,'depart_code',Depart::model()->getListDataByEparchy($model->eparchy_code),array('prompt'=>'---------',)); ?>
            <?php echo $form->error($model,'depart_code'); ?>
            <?php echo $form->hiddenField($model,'eparchy_code'); ?>
          </td>
        </tr>
        <?php }else { ?>
        <tr>
          <th class="tleft"><?php echo $form->label($model,'depart_code'); ?></th>
          <td colspan="3">            
            <?php echo Depart::model()->getNameByKey($model->depart_code);?>
            <?php echo $form->hiddenField($model,'depart_code')?>
            <?php echo $form->hiddenField($model,'eparchy_code')?>
          </td>
        </tr>
        <?php } ?>
      </table>
      <p class="inquiry">
      	<?php echo CHtml::submitButton('查询',array('class'=>'btn','name'=>'search',))?>
      	<?php echo CHtml::resetButton('重置',array('class'=>'btn'))?>
      </p>
      <!--div.section -->
    </div>
    <div class="section">
      <h4 class="heading_bg">查询结果</h4>
      	<?php $this->widget('zii.widgets.grid.CGridView', array(
			'dataProvider'=>$dataProvider,
			'ajaxUpdate'=>false,    //禁用AJAX
			//'filter'=>$model,
			'summaryCssClass' => 'summary1',
			'pagerCssClass'=>'pager1',
			'pager'=>array(
				'header'=>'',
				),
			'columns'=>array(
				array(
					'name'=>'trade_date',
                    'value'=>'$data->trade_date',
                    'htmlOptions'=>array('nowrap'=>'nowrap'),
                    'headerHtmlOptions'=>array('nowrap'=>'nowrap'),
                    //'header'=>'日期'
				),
				array(
                    'value'=>'$row+1',
                    'header'=>'序号',
                    'htmlOptions'=>array('nowrap'=>'nowrap'),
                    'headerHtmlOptions'=>array('nowrap'=>'nowrap'),
				),
				array(
					'name'=>'tradeStaff.eparchy_code',
					'value'=>'$data->tradeStaff->eparchyCode->eparchy_name',
					'htmlOptions'=>array('nowrap'=>'nowrap'),
					'headerHtmlOptions'=>array('nowrap'=>'nowrap'),
				),
				array(
					'name'=>'tradeStaff.depart_code',
					'value'=>'$data->tradeStaff->departCode->depart_name',
					'htmlOptions'=>array('nowrap'=>'nowrap'),
					'headerHtmlOptions'=>array('nowrap'=>'nowrap'),
				),
				array(
					'name'=>'trade_staff',
					'value'=>'$data->tradeStaff->user_name',
					'htmlOptions'=>array('nowrap'=>'nowrap'),
					'headerHtmlOptions'=>array('nowrap'=>'nowrap'),
				),
				array(
					'name'=>'trade_method',
					'value'=>'$data->tradeMethod->method_name',
					'htmlOptions'=>array('nowrap'=>'nowrap'),
					'headerHtmlOptions'=>array('nowrap'=>'nowrap'),
				),
				
				array(
					'name'=>'producttype_code',
					'value'=>'$data->producttypeCode->producttype_name',
					'htmlOptions'=>array('nowrap'=>'nowrap'),
					'headerHtmlOptions'=>array('nowrap'=>'nowrap'),
				),
				array(
					'name'=>'product_id',
					'value'=>'$data->product->specification',
					'htmlOptions'=>array('nowrap'=>'nowrap'),
					'headerHtmlOptions'=>array('nowrap'=>'nowrap'),
				),
				array(
					'name'=>'trade_number',
					'value'=>'$data->trade_number',
					'htmlOptions'=>array('nowrap'=>'nowrap'),
					'headerHtmlOptions'=>array('nowrap'=>'nowrap'),
				),
				array(
					'name'=>'imei',
					'value'=>'$data->imei',
					'htmlOptions'=>array('nowrap'=>'nowrap'),
					'headerHtmlOptions'=>array('nowrap'=>'nowrap'),
				),
				array(
					'name'=>'all_fee',
					'value'=>'$data->all_fee',
					'htmlOptions'=>array('nowrap'=>'nowrap'),
					'headerHtmlOptions'=>array('nowrap'=>'nowrap'),
				),
				array(
					'name'=>'ready_money',
					'value'=>'$data->ready_money',
					'htmlOptions'=>array('nowrap'=>'nowrap'),
					'headerHtmlOptions'=>array('nowrap'=>'nowrap'),
				),
				array(
					'name'=>'pos_money',
					'value'=>'$data->pos_money',
					'htmlOptions'=>array('nowrap'=>'nowrap'),
					'headerHtmlOptions'=>array('nowrap'=>'nowrap'),
				),
				array(
					'name'=>'transfer_money',
					'value'=>'$data->transfer_money',
					'htmlOptions'=>array('nowrap'=>'nowrap'),
					'headerHtmlOptions'=>array('nowrap'=>'nowrap'),
				),
				array(
					'name'=>'all_money',
					'value'=>'$data->all_money',
					'htmlOptions'=>array('nowrap'=>'nowrap'),
					'headerHtmlOptions'=>array('nowrap'=>'nowrap'),
				),
					
				array(
					'name'=>'trade_dept',
					'value'=>'$data->trade_dept',
					'htmlOptions'=>array('nowrap'=>'nowrap'),
					'headerHtmlOptions'=>array('nowrap'=>'nowrap'),
				),
				array(
					'name'=>'examine_staff',
					'value'=>'$data->examine_staff',
					'htmlOptions'=>array('nowrap'=>'nowrap'),
					'headerHtmlOptions'=>array('nowrap'=>'nowrap'),
				),
				array(
					'name'=>'dept_minus',
					'value'=>'$data->dept_minus',
					'htmlOptions'=>array('nowrap'=>'nowrap'),
					'headerHtmlOptions'=>array('nowrap'=>'nowrap'),
				),
				array(
					'name'=>'remark',
					'value'=>'$data->remark',
					'htmlOptions'=>array('nowrap'=>'nowrap'),
					'headerHtmlOptions'=>array('nowrap'=>'nowrap'),
				),
					/*
				array(
					'name'=>'create_time',
					'type'=>'datetime',
					//'filter'=>false,
				),*/
			    /*
				array(
					'class'=>'CButtonColumn',
					'htmlOptions'=>array('nowrap'=>'nowrap'),
					'headerHtmlOptions'=>array('nowrap'=>'nowrap'),
					'header'=>'操作',
				),
				*/
				array(
				    'class'=>'CButtonColumn',
					'htmlOptions'=>array('nowrap'=>'nowrap'),
					'headerHtmlOptions'=>array('nowrap'=>'nowrap'),
					'header'=>'操作',
					'template'=>'{delete}',
					'deleteButtonUrl'=>'"generaldelete/id/".$data->id',
					'deleteConfirmation'=>'确认删除该订单吗?',
					'cssClassExpression'=>'((Yii::app()->user->id==$data->update_staff)&&$data->trade_date==date("Y-m-d"))?"show":"show"',
				),
			), 
		)); ?>
      <p class="inquiry">
      	<?php echo CHtml::submitButton('导出',array('class'=>'btn','name'=>'export',))?>
      </p>
      <!-- <div class="content-link"><a href="#wrapper">▲回到顶部</a></div> -->
    </div>
<?php echo $form->hiddenField($model,'old_depart_code');?>
<?php echo $form->hiddenField($model,'old_start_date');?>
<?php echo $form->hiddenField($model,'old_end_date');?>
<?php $this->endWidget(); ?>
  <!-- div#content end -->
</div>
